const express = require('express');

const app = express();

app.all('*',(req,res,next)=>{
    res.header('Access-Control-Allow-Origin', '*');
    res.header('Access-Control-Allow-Headers', 'Content-Type');
    res.header('Access-Control-Allow-Methods', '*');
    res.header('Content-Type','application/json;charset=utf-8');
    next();
})

app.use(express.static(__dirname));//以当前目录作为静态服务器
app.get('/getUser',function(req,res){
  res.send([{name:'zfpx',age:8}])
})
app.get('/',function(req,res){
  res.sendFile('./get.html',{root:__dirname})
})

app.get('/category',(req,res)=>{
    res.json({
        menuList:[
            {pid:-1,name:'服装',id:1,auth:'clothing'},
            {pid:1,name:'男装',id:4,auth:'men-wear'},
            {pid:1,name:'女装',id:5,auth:'women-wear'},
            {pid:5,name:'裙子',id:6,auth:'skirt'},
            {pid:4,name:'衬衫',id:7,auth:'shirt'},
            {pid:-1,name:'酒类',id:2,auth:'liquor'},
            // {pid:-1,name:'医药',id:3,auth:'medicine'},
        ]
    })
});
app.get('/getSlider',(req,res)=>{
  res.json({
      data:[
        {contentId:29879439,photoUrl:'http://pic4.ablesky.cn/content/pic/org_template_index_picture/2017/12/30/708080b2-5008-4981-9718-76fa636e289f.png',url:'http://www.zhufengpeixun.com/main/course/index.html'},
        {contentId:29544573,photoUrl:'http://img.zhufengpeixun.cn/zfjgk.png',url:'http://www.zhufengpeixun.com/main/course/index.html'},
        {contentId:29544575,photoUrl:'http://img.zhufengpeixun.cn/reactposter.png',url:'http://www.zhufengpeixun.com/main/course/index.html'},
        {contentId:29544577,photoUrl:'http://img.zhufengpeixun.cn/rnposter.png',url:'http://www.zhufengpeixun.com/main/course/index.html'}
      ],
      status:'ok'
  })
});
app.get('/getLesson',(req,res)=>{
  res.json({
      data:[
          {id:1,category:'js',poster:'http://www.zhufengpeixun.com/react/img/react.jpg',score:98,stars:5,price:'￥100.00元',title:'1.React全栈架构',url:'http://www.zhufengpeixun.com/themes/jianmo2/images/react.png',video:'http://7xil5b.com1.z0.glb.clouddn.com/zhufengpeixun.mp4'},
          {id:2,category:'vue',poster:'http://img.zhufengpeixun.cn/vueposters.png',score:99,stars:4,price:'￥200.00元',title:'2.vue全栈架构',url:'http://www.zhufengpeixun.com/themes/jianmo2/images/react.png',video:'http://7xil5b.com1.z0.glb.clouddn.com/zhufengpeixun.mp4'},
          {id:3,category:'react',poster:'http://www.zhufengpeixun.com/react/img/react.jpg',score:78,stars:3,price:'￥300.00元',title:'3.React全栈架构',url:'http://www.zhufengpeixun.com/themes/jianmo2/images/react.png',video:'http://7xil5b.com1.z0.glb.clouddn.com/zhufengpeixun.mp4'},
          {id:4,category:'node',poster:'http://img.zhufengpeixun.cn/vueposters.png',score:68,stars:5,price:'￥400.00元',title:'4.vue全栈架构',url:'http://www.zhufengpeixun.com/themes/jianmo2/images/react.png',video:'http://7xil5b.com1.z0.glb.clouddn.com/zhufengpeixun.mp4'},
          {id:5,category:'h5',poster:'http://www.zhufengpeixun.com/react/img/react.jpg',score:88,stars:4,price:'￥500.00元',title:'5.React全栈架构',url:'http://www.zhufengpeixun.com/themes/jianmo2/images/react.png',video:'http://7xil5b.com1.z0.glb.clouddn.com/zhufengpeixun.mp4'},
          {id:6,category:'css3',poster:'http://img.zhufengpeixun.cn/vueposters.png',score:198,stars:5,price:'￥600.00元',title:'6.vue全栈架构',url:'http://www.zhufengpeixun.com/themes/jianmo2/images/react.png',video:'http://7xil5b.com1.z0.glb.clouddn.com/zhufengpeixun.mp4'}
      ],
      status:'ok'
  })
});
app.get('/hot_lesson',(req,res)=>{
  res.json({
      data:["vue","react","webpack","小程序","HTML5","CSS3","JavaScript","anguar"],
      status:'ok'
  })
});
app.get('/query',(req,res)=>{
  res.json({
      data:{
        total:14,
        lesson:[
          {id:1,category:'js',poster:'http://www.zhufengpeixun.com/react/img/react.jpg',score:98,stars:5,price:'￥100.00元',title:'1.React全栈架构',url:'http://www.zhufengpeixun.com/themes/jianmo2/images/react.png',video:'http://7xil5b.com1.z0.glb.clouddn.com/zhufengpeixun.mp4'},
          {id:2,category:'vue',poster:'http://img.zhufengpeixun.cn/vueposters.png',score:99,stars:4,price:'￥200.00元',title:'2.vue全栈架构',url:'http://www.zhufengpeixun.com/themes/jianmo2/images/react.png',video:'http://7xil5b.com1.z0.glb.clouddn.com/zhufengpeixun.mp4'},
          {id:3,category:'react',poster:'http://www.zhufengpeixun.com/react/img/react.jpg',score:78,stars:3,price:'￥300.00元',title:'3.React全栈架构',url:'http://www.zhufengpeixun.com/themes/jianmo2/images/react.png',video:'http://7xil5b.com1.z0.glb.clouddn.com/zhufengpeixun.mp4'},
          {id:4,category:'node',poster:'http://img.zhufengpeixun.cn/vueposters.png',score:68,stars:5,price:'￥400.00元',title:'4.vue全栈架构',url:'http://www.zhufengpeixun.com/themes/jianmo2/images/react.png',video:'http://7xil5b.com1.z0.glb.clouddn.com/zhufengpeixun.mp4'},
          {id:5,category:'h5',poster:'http://www.zhufengpeixun.com/react/img/react.jpg',score:88,stars:4,price:'￥500.00元',title:'5.React全栈架构',url:'http://www.zhufengpeixun.com/themes/jianmo2/images/react.png',video:'http://7xil5b.com1.z0.glb.clouddn.com/zhufengpeixun.mp4'},
          {id:6,category:'css3',poster:'http://img.zhufengpeixun.cn/vueposters.png',score:198,stars:5,price:'￥600.00元',title:'6.vue全栈架构',url:'http://www.zhufengpeixun.com/themes/jianmo2/images/react.png',video:'http://7xil5b.com1.z0.glb.clouddn.com/zhufengpeixun.mp4'},
          {id:7,category:'react',poster:'http://www.zhufengpeixun.com/react/img/react.jpg',score:78,stars:3,price:'￥300.00元',title:'3.React全栈架构',url:'http://www.zhufengpeixun.com/themes/jianmo2/images/react.png',video:'http://7xil5b.com1.z0.glb.clouddn.com/zhufengpeixun.mp4'},
          {id:8,category:'node',poster:'http://img.zhufengpeixun.cn/vueposters.png',score:68,stars:5,price:'￥400.00元',title:'4.vue全栈架构',url:'http://www.zhufengpeixun.com/themes/jianmo2/images/react.png',video:'http://7xil5b.com1.z0.glb.clouddn.com/zhufengpeixun.mp4'},
          {id:9,category:'h5',poster:'http://www.zhufengpeixun.com/react/img/react.jpg',score:88,stars:4,price:'￥500.00元',title:'5.React全栈架构',url:'http://www.zhufengpeixun.com/themes/jianmo2/images/react.png',video:'http://7xil5b.com1.z0.glb.clouddn.com/zhufengpeixun.mp4'},
          {id:10,category:'css3',poster:'http://img.zhufengpeixun.cn/vueposters.png',score:198,stars:5,price:'￥600.00元',title:'6.vue全栈架构',url:'http://www.zhufengpeixun.com/themes/jianmo2/images/react.png',video:'http://7xil5b.com1.z0.glb.clouddn.com/zhufengpeixun.mp4'}
        ]
      },
      status:'ok'
  })
});
app.get('/detail',(req,res)=>{
  res.json({
      data:[{
        title:"课程详情",
        content:"通过珠峰培训的node.js课程，全面提高JavaScript水平,珠峰培训，专注JavaScript培训，从前端到后台，我们的课程体系最系统最全面最深入！学了Node，你不但让自己的JS技术水平大涨，还会对JS有一个更全高全面高层次的认识，甚至对互联网技术的把握和对互联网的趋势有更好的认识！"
      },{
        title:"教学理念",
        content:"珠峰培训的Node.js课程，它不仅仅是前端JS的延伸，也是一门后台语言，不但可以提高前端程序员的工作效率，更可以将触角伸向后端和服务器，让你华丽转身全栈开发,可以独挑项目大梁，成为公司不可或缺的核心人才！"
      },{
        title:"测试详情",
        content:"通过珠峰培训的node.js课程，全面提高JavaScript水平,珠峰培训，专注JavaScript培训，从前端到后台，我们的课程体系最系统最全面最深入！学了Node，你不但让自己的JS技术水平大涨，还会对JS有一个更全高全面高层次的认识，甚至对互联网技术的把握和对互联网的趋势有更好的认识！"
      },{
        title:"测试理念",
        content:"珠峰培训的Node.js课程，它不仅仅是前端JS的延伸，也是一门后台语言，不但可以提高前端程序员的工作效率，更可以将触角伸向后端和服务器，让你华丽转身全栈开发,可以独挑项目大梁，成为公司不可或缺的核心人才！"
      }],
      status:'ok'
  })
});
app.listen(3000,()=>{
  console.log(`访问路径：http://localhost:3000/`)
});//http://localhost:3000/category
//启服务：vscode右键 Run Code，或者cmd里 node server.js
//终止服务：vscode输出栏右键 Stop Code Run
//如果忘记终止切换项目了，需要在cmd里：
//netstat -ano | findstr :3000    记录最右边的PID
//taskkill /PID 4496 /F           终止进程